home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / CIncludes / StandardFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  7.8 KB  |  258 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        StandardFile.h
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. */
  11.  
  12. #ifndef __STANDARDFILE__
  13. #define __STANDARDFILE__
  14.  
  15. #ifndef __TYPES__
  16. #include <Types.h>
  17. #endif
  18.  
  19. #ifndef __DIALOGS__
  20. #include <Dialogs.h>
  21. #endif
  22.  
  23. #ifndef __FILES__
  24. #include <Files.h>
  25. #endif
  26.  
  27.  
  28. enum {
  29.  
  30.  
  31. /* resource IDs and item offsets of pre-7.0 dialogs */
  32.     putDlgID = -3999,
  33.     putSave = 1,
  34.     putCancel = 2,
  35.     putEject = 5,
  36.     putDrive = 6,
  37.     putName = 7,
  38.  
  39.     getDlgID = -4000,
  40.     getOpen = 1,
  41.     getCancel = 3,
  42.     getEject = 5,
  43.     getDrive = 6,
  44.     getNmList = 7,
  45.     getScroll = 8,
  46.  
  47. /* resource IDs and item offsets of 7.0 dialogs */
  48.     sfPutDialogID = -6043,
  49.     sfGetDialogID = -6042,
  50.     sfItemOpenButton = 1,
  51.     sfItemCancelButton = 2,
  52.     sfItemBalloonHelp = 3,
  53.     sfItemVolumeUser = 4,
  54.     sfItemEjectButton = 5
  55. };
  56. enum {
  57.     sfItemDesktopButton = 6,
  58.     sfItemFileListUser = 7,
  59.     sfItemPopUpMenuUser = 8,
  60.     sfItemDividerLinePict = 9,
  61.     sfItemFileNameTextEdit = 10,
  62.     sfItemPromptStaticText = 11,
  63.     sfItemNewFolderUser = 12,
  64.  
  65.  
  66. /* pseudo-item hits for use in DlgHook */
  67.     sfHookFirstCall = -1,
  68.     sfHookCharOffset = 0x1000,
  69.     sfHookNullEvent = 100,
  70.     sfHookRebuildList = 101,
  71.     sfHookFolderPopUp = 102,
  72.     sfHookOpenFolder = 103,
  73.  
  74.  
  75. /* the following are only in system 7.0+ */
  76.     sfHookOpenAlias = 104,
  77.     sfHookGoToDesktop = 105,
  78.     sfHookGoToAliasTarget = 106,
  79.     sfHookGoToParent = 107,
  80.     sfHookGoToNextDrive = 108,
  81.     sfHookGoToPrevDrive = 109,
  82.     sfHookChangeSelection = 110
  83. };
  84. enum {
  85.     sfHookSetActiveOffset = 200,
  86.     sfHookLastCall = -2
  87.  
  88. /* the refcon field of the dialog record during a
  89.  modalfilter or dialoghook contains one of the following */
  90.  
  91. #define sfMainDialogRefCon 'stdf'
  92. #define sfNewFolderDialogRefCon 'nfdr'
  93. #define sfReplaceDialogRefCon 'rplc'
  94. #define sfStatWarnDialogRefCon 'stat'
  95. #define sfLockWarnDialogRefCon 'lock'
  96. #define sfErrorDialogRefCon 'err '
  97. };
  98.  
  99. struct SFReply {
  100.     Boolean good;
  101.     Boolean copy;
  102.     OSType fType;
  103.     short vRefNum;
  104.     short version;
  105.     Str63 fName;
  106. };
  107.  
  108. typedef struct SFReply SFReply;
  109.  
  110. struct StandardFileReply {
  111.     Boolean sfGood;
  112.     Boolean sfReplacing;
  113.     OSType sfType;
  114.     FSSpec sfFile;
  115.     ScriptCode sfScript;
  116.     short sfFlags;
  117.     Boolean sfIsFolder;
  118.     Boolean sfIsVolume;
  119.     long sfReserved1;
  120.     short sfReserved2;
  121. };
  122.  
  123. typedef struct StandardFileReply StandardFileReply;
  124.  
  125.  
  126. typedef pascal short (*DlgHookProcPtr)(short item, DialogPtr theDialog);
  127. typedef pascal Boolean (*FileFilterProcPtr)(ParmBlkPtr PB);
  128.  
  129. /* the following also include an extra parameter of "your data pointer" */
  130. typedef pascal short (*DlgHookYDProcPtr)(short item, DialogPtr theDialog, void *yourDataPtr);
  131. typedef pascal Boolean (*ModalFilterYDProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit, void *yourDataPtr);
  132. typedef pascal Boolean (*FileFilterYDProcPtr)(ParmBlkPtr PB, void *yourDataPtr);
  133. typedef pascal void (*ActivateYDProcPtr)(DialogPtr theDialog, short itemNo, Boolean activating, void *yourDataPtr);
  134.  
  135. typedef OSType SFTypeList[4];
  136.  
  137. #ifdef __cplusplus
  138. extern "C" {
  139. #endif
  140. pascal void SFPutFile(Point where,
  141.                       ConstStr255Param prompt,
  142.                       ConstStr255Param origName,
  143.                       DlgHookProcPtr dlgHook,
  144.                       SFReply *reply)
  145.     = {0x3F3C,0x0001,0xA9EA}; 
  146.  
  147. pascal void SFGetFile(Point where,
  148.                       ConstStr255Param prompt,
  149.                       FileFilterProcPtr fileFilter,
  150.                       short numTypes,
  151.                       SFTypeList typeList,
  152.                       DlgHookProcPtr dlgHook,
  153.                       SFReply *reply)
  154.     = {0x3F3C,0x0002,0xA9EA}; 
  155.  
  156. pascal void SFPPutFile(Point where,
  157.                        ConstStr255Param prompt,
  158.                        ConstStr255Param origName,
  159.                        DlgHookProcPtr dlgHook,
  160.                        SFReply *reply,
  161.                        short dlgID,
  162.                        ModalFilterProcPtr filterProc)
  163.     = {0x3F3C,0x0003,0xA9EA}; 
  164.  
  165. pascal void SFPGetFile(Point where,
  166.                        ConstStr255Param prompt,
  167.                        FileFilterProcPtr fileFilter,
  168.                        short numTypes,
  169.                        SFTypeList typeList,
  170.                        DlgHookProcPtr dlgHook,
  171.                        SFReply *reply,
  172.                        short dlgID,
  173.                        ModalFilterProcPtr filterProc)
  174.     = {0x3F3C,0x0004,0xA9EA}; 
  175.  
  176. pascal void StandardPutFile(ConstStr255Param prompt,
  177.                             ConstStr255Param defaultName,
  178.                             StandardFileReply *reply)
  179.     = {0x3F3C,0x0005,0xA9EA}; 
  180.  
  181. pascal void StandardGetFile(FileFilterProcPtr fileFilter,
  182.                             short numTypes,
  183.                             SFTypeList typeList,
  184.                             StandardFileReply *reply)
  185.     = {0x3F3C,0x0006,0xA9EA}; 
  186.  
  187. pascal void CustomPutFile(ConstStr255Param prompt,
  188.                           ConstStr255Param defaultName,
  189.                           StandardFileReply *reply,
  190.                           short dlgID,
  191.                           Point where,
  192.                           DlgHookYDProcPtr dlgHook,
  193.                           ModalFilterYDProcPtr filterProc,
  194.                           short *activeList,
  195.                           ActivateYDProcPtr activateProc,
  196.                           void *yourDataPtr)
  197.     = {0x3F3C,0x0007,0xA9EA}; 
  198.  
  199. pascal void CustomGetFile(FileFilterYDProcPtr fileFilter,
  200.                           short numTypes,
  201.                           SFTypeList typeList,
  202.                           StandardFileReply *reply,
  203.                           short dlgID,
  204.                           Point where,
  205.                           DlgHookYDProcPtr dlgHook,
  206.                           ModalFilterYDProcPtr filterProc,
  207.                           short *activeList,
  208.                           ActivateYDProcPtr activateProc,
  209.                           void *yourDataPtr)
  210.     = {0x3F3C,0x0008,0xA9EA}; 
  211.  
  212. void sfpputfile(Point *where,char *prompt,char *origName,DlgHookProcPtr dlgHook,
  213.     SFReply *reply,short dlgID,ModalFilterProcPtr filterProc); 
  214. void sfgetfile(Point *where,char *prompt,FileFilterProcPtr fileFilter,short numTypes,
  215.     SFTypeList typeList,DlgHookProcPtr dlgHook,SFReply *reply); 
  216. void sfpgetfile(Point *where,char *prompt,FileFilterProcPtr fileFilter,
  217.     short numTypes,SFTypeList typeList,DlgHookProcPtr dlgHook,SFReply *reply,
  218.     short dlgID,ModalFilterProcPtr filterProc); 
  219. void sfputfile(Point *where,char *prompt,char *origName,DlgHookProcPtr dlgHook,
  220.     SFReply *reply); 
  221.  
  222. /* 
  223.     
  224.         New StandardFile routine comments:
  225.     
  226.         activeList is pointer to array of integer (16-bits).
  227.         first integer is length of list.
  228.         following integers are possible activatable DITL items, in
  229.         the order that the tab key will cycle through.  The first
  230.         in the list is the item made active when dialog is first shown.
  231.     
  232.         activateProc is a pointer to a procedure like:
  233.     
  234.             PROCEDURE MyActivateProc(theDialog:     DialogPtr;
  235.                                      itemNo:        INTEGER;
  236.                                      activating:    BOOLEAN;
  237.                                      yourDataPtr:    Ptr);
  238.     
  239.         The activateProc is called with activating=FALSE on the itemNo
  240.         about to deactivate then with activating=TRUE on the itemNo
  241.         about to become the active item. (like activate event)
  242.     
  243.         yourDataPtr is a nice little extra that makes life easier without
  244.         globals.  CustomGetFile & CustomPPutFile when calling any of their
  245.         call back procedures, pushes the extra parameter of yourDataPtr on
  246.         the stack.
  247.     
  248.         In addition the filterProc in CustomGetFile & CustomPPutFile is called
  249.         before before SF does any mapping, instead of after.
  250. */
  251.  
  252.  
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256.  
  257. #endif
  258.